package io.renren.modules.sys.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BalanceLogEntity;
import io.renren.modules.app.service.BalanceLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 账户余额日志
 *
 * @author
 * @email
 * @date 2021-01-12 16:56:22
 */
@RestController
@RequestMapping("sys/balancelog")
@Api(value = "账户余额日志", tags = "后台管理：账户余额管理")
public class SysBalanceLogController {
    @Autowired
    private BalanceLogService balanceLogService;



    /**
     * 自定义分页
     */
    @GetMapping("/selectBalanceLogPage")
    @ApiOperation(value = "查询账户余额日志", notes = "传入balanceLog", response = BalanceLogEntity.class)
    public R selectBalanceLogPage( BalanceLogEntity balanceLogEntity, Page page){
        System.out.println(balanceLogEntity.toString());
        PageUtils pages = balanceLogService.selectBalanceLogPage(page,balanceLogEntity);
        return R.ok().put("page", pages);
    }
    /**
     * 分页
     */
    @GetMapping("/balanceLog")
    @ApiOperation(value = "查询账户余额日志", notes = "传入balanceLog", response = BalanceLogEntity.class)
    public R balanceLog( BalanceLogEntity balanceLogEntity, Page page){
        System.out.println(balanceLogEntity.toString());
        System.out.println(page.toString());
        PageUtils pages = balanceLogService.balanceLogPage(page,balanceLogEntity);
        return R.ok().put("page", pages);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation(value = "查询账户余额日志", notes = "传入balanceLog", response = BalanceLogEntity.class)
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = balanceLogService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation(value = "查询账户余额日志", notes = "传入id", response = BalanceLogEntity.class)
    public R info(@PathVariable("id") Integer id){
		BalanceLogEntity balanceLog = balanceLogService.getById(id);

        return R.ok().put("balanceLog", balanceLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation(value = "保存账户余额日志", notes = "传入balanceLog")
    public R save(@RequestBody BalanceLogEntity balanceLog){
		balanceLogService.save(balanceLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation(value = "修改账户余额日志", notes = "传入balanceLog")
    public R update(@RequestBody BalanceLogEntity balanceLog){
		balanceLogService.updateById(balanceLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation(value = "删除账户余额日志", notes = "传入ids[1,2,3,4]")
    public R delete(@RequestBody Integer[] ids){
		balanceLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
